
Page({
  data:{
    catelist:["男装","女装","零食","家电","床上用品","家具"],
    bannerlist: [{
      url:"../../images/banner1.jpg"
    },{
      url:"../../images/banner2.jpg"
    }
    ,{
      url:"../../images/banner3.jpg"
    }],
    latitude:"",
    longitude:"",
    danmulist:[
    {
      text:"网院",
      color:"ff0000",
      time:1
    },
    {
      text:"电大",
      color:"E64E69",
      time:30,
    }
    ],

  },
  onLoad() {

  },
  saveUserInfo:function(){
    //同步缓存
    var data = {"name":"小杨","student_id":"201965110437"}
      wx.setStorageSync('userinfo', data)
   //异步缓存
    wx.setStorage({
      data: {"sex":"男","age":21},
      key: 'studentinfo',
    })
  },
  getUserInfo:function(){
    //同步获取缓存数据
    var studentinfo =  wx.getStorageSync('studentinfo');
    console.log(studentinfo);
    //异步获取缓存
    wx.getStorage({
      key:"userinfo",
      success(res){
        console.log(res);
      },
    })
    //获取小程序中所有缓存信息(key)
    success: (option) => {
      console.log(option)
    }
  },
  removeUserInfo:function(){
    //异步移除
    wx.removeStorage({
      key: 'userinfo',
    })
    wx.removeStorageSync('studentionfo');
  },
  getLocal:function(){
    var then = this;
    wx.getLocation({
      success(res){
        then.setData({
          latitude:res.latitude,
          longitude:res.longitude
        })
      }
    })
  },
  openMap:function(){
    var then=this;
      wx.openLocation({
        latitude: then.data.latitude,
        longitude: then.data.longitude,
        name:"湖南开放大学宗教楼1104",
        address:"湖南省长沙市天心区青园路168号1104"
      })
  },
  selectLocal:function(){
    var then = this;
    wx.chooseLocation({
      latitude: then.data.latitude,
      longitude:then.data.longitude
    })

  },
  // checkboxChange:function(e){
  //   var then = this;                                                                                                                                                  
  //   var likestr = "";
  //   for (let index = 0; index < e.detail.value.length; index++) {
  //     likestr=likestr+ e.detail.value[index];
     
  //   }
  //   then.setData({
  //     likes:likestr
  //   })
  //   console.log(e)
  //   console.log(e.detail.value[0])   
  // }
})

